from django.db import models


# Create your models here.
class User_info(models.Model):
    username = models.CharField(max_length=32)
    password = models.CharField(max_length=32)


class SensorMonitor_info(models.Model):
    time = models.DateField(max_length=64)
    temperature = models.FloatField(max_length=64)
    humidity = models.FloatField(max_length=64)
    co2 = models.FloatField(max_length=64)
    luminance = models.FloatField(max_length=64)
    soi_humidity = models.FloatField(max_length=64)

class chuanganqi(models.Model):
    temperature =models.FloatField(max_length=64)
    humidity = models.FloatField(max_length=64)
    light=models.FloatField(max_length=64)
class agriculture_info(models.Model):
    name = models.CharField(max_length=64)


class api_irrigationschedule_info(models.Model):
    SCHEDULE_TYPE_CHOICES = (
        ('每天定时', '每天定时'),
        ('每周定时', '每周定时'),
        ('每月定时', '每月定时'),
        ('每年定时', '每年定时'),
    )
    schedule_type = models.CharField(max_length=50, choices=SCHEDULE_TYPE_CHOICES)
    valve_control = models.CharField(max_length=10, choices=(('开启', '开启'), ('关闭', '关闭')))
    start_time = models.CharField(max_length=50)
    duration = models.CharField(max_length=50)

class ThresholdIrrigation(models.Model):
    VALVE_CONTROL_CHOICES = (
        ('开启', '开启'),
        ('关闭', '关闭'),
    )
    TEMPERATURE_THRESHOLD_CHOICES = (
        ('大于', '大于'),
        ('小于', '小于'),
    )
    HUMIDITY_THRESHOLD_CHOICES = TEMPERATURE_THRESHOLD_CHOICES
    CO2_THRESHOLD_CHOICES = TEMPERATURE_THRESHOLD_CHOICES
    LIGHT_THRESHOLD_CHOICES = TEMPERATURE_THRESHOLD_CHOICES
    SOIL_MOISTURE_THRESHOLD_CHOICES = TEMPERATURE_THRESHOLD_CHOICES

    id = models.AutoField(primary_key=True)
    valve_control = models.CharField(max_length=10, choices=VALVE_CONTROL_CHOICES)
    valve_hold_time = models.IntegerField()
    temperature_threshold = models.CharField(max_length=10, choices=TEMPERATURE_THRESHOLD_CHOICES)
    temperature_value = models.FloatField()
    humidity_threshold = models.CharField(max_length=10, choices=HUMIDITY_THRESHOLD_CHOICES)
    humidity_value = models.FloatField()
    co2_threshold = models.CharField(max_length=10, choices=CO2_THRESHOLD_CHOICES)
    co2_value = models.FloatField()
    light_threshold = models.CharField(max_length=10, choices=LIGHT_THRESHOLD_CHOICES)
    light_value = models.FloatField()
    soil_moisture_threshold = models.CharField(max_length=10, choices=SOIL_MOISTURE_THRESHOLD_CHOICES)
    soil_moisture_value = models.FloatField()